#include "stdio.h"
#include "stdlib.h"

typedef int DataType;
#define M 100
typedef struct {
    DataType *base;
    int front;
    int rear;
} SqQueue;

int InitQueue(SqQueue *Q) {
    Q->base = malloc(sizeof(DataType) * M);
    Q->front = 0;
    Q->rear = 0;
}

int QueueLength(SqQueue Q) {
    return Q.rear - Q.front;
}

int EnQueue(SqQueue *Q, DataType e) {
    if((Q->rear + 1) % M == Q->front) {
        return 1;
    }
    Q->base[Q->rear] = e;
    Q->rear = (Q->rear + 1) % M;
    return 0;
}

int DeQueue(SqQueue *Q, DataType *e) {
    if(Q->front == Q->rear) {
        return 1;
    }
    *e = Q->base[Q->front];
    Q->front = (Q->front + 1) % M;
    return 0;
}























